package com.xiaodu.jdbc.config;

import com.alibaba.druid.support.http.StatViewServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.http.HttpServlet;

/**
 * @author: dutianjie
 * @date: 2021/4/12
 * @version: v1.0.0
 * @description: 描述
 **/
@Configuration
public class WebConfig {

    /**
     * 配置 druid  ui页面servlet  statViewServlet
     * @return
     */
    @Bean
    public ServletRegistrationBean<HttpServlet> servletRegistrationBean() {
        ServletRegistrationBean<HttpServlet> servletRegistrationBean = new ServletRegistrationBean<>();
        servletRegistrationBean.setServlet(statViewServlet());
        servletRegistrationBean.addUrlMappings("/druid/*");
        return servletRegistrationBean;
    }

    @Bean
    public StatViewServlet statViewServlet() {
        return new StatViewServlet();
    }

}
